//
//  SEPrescriptionOrderModel.swift
//  SmartEyeForPatient
//
//  Created by qdsg on 2021/5/7.
//

import HandyJSON

/// 订单状态（1待付款，2待取药，3待发货，4待签收，5待评价，6已完成，7已取消，8退款关闭）
enum prescriptionOrderStatus: Int, HandyJSONEnum {
    case waitpay = 1
    case waitget
    case waitsend
    case waitsign
    case waitcomment
    case finish
    case cancel
    case close
    case unknown

    var title: String {
        switch self {
        case .waitpay: return "待支付"
        case .waitget: return "待取药"
        case .waitsend: return "待发货"
        case .waitsign: return "待签收"
        case .waitcomment: return "待评价"
        case .finish: return "已完成"
        case .cancel: return "已取消"
        case .close: return "退款关闭"
        case .unknown: return "未知状态"
        }
    }

    var isHiddenPay: Bool {
//        switch self {
//        case .waitpay: return false
//        default: return true
//        }
        return true
    }

    var isHiddenCancel: Bool {
        return true
    }

    var isHiddenDetail: Bool {
//        switch self {
//        case .waitpay, .unknown: return true
//        default: return false
//        }
        return false
    }

    var isHiddenLogstics: Bool {
//        switch self {
//        case .waitsign, .waitcomment, .finish:
//            return false
//        default:
//            return true
//        }
        return true
    }

    var isHiddenCheck: Bool {
//        return !isHiddenPay
        return false
    }

}

struct SEPrescriptionOrderListModel: HandyJSON {
    var pageNum: Int = 0
    var pageSize: Int = 0
    var total: Int = 0
    var list: [SEPrescriptionOrderDetailModel] = []
}

/// 处方订单详情
struct SEPrescriptionOrderDetailModel: HandyJSON {
    var id: String = ""
    var orderId: String = ""
    var createTime: String = ""
    var updateTime: String = ""
    var creator: String = ""
    var `operator`: String = ""
    var isDeleted: Int = 0
    var bisType: Int = 0        // 业务类型
    var bisId: String = ""         // 业务id
    var patientId: String = ""
    var patientName: String = ""
    var patientSex: Int = 0
    var patientAge: String = ""
    var patientPhone: String = ""
    var patientIdcard: String = ""
    var doctorId: String = ""      // 开处方的医生id
    var doctor: String = ""       // 开处方的医生
    var jobTitle: String = ""
    var hospitalId: String = ""     // 开方医院id
    var hospitalName: String = ""
    var totalExpense: Double = 0   // 处方的总费用
    var auditorId: String = ""     // 审核人id
    var auditor: String = ""      // 审核人
    var status: Int = 0 // 处方状态：0未审核，1审核通过2驳回,3付款成功,4医生撤销
    var passTime: String = ""         // 审核时间
    var reject: String = ""         // 驳回理由
    var isChild: Int = 0        // 是否儿童处方（1是，0否）
    var proposal: String = ""      // 医生建议
    var remark: String = ""        // 用药嘱托
    var list: [SEPrescriptionDrugModel] = []
    var detailDtos: [SEPrescriptionDiagnosis] = []
    var illness: String = ""        // 病情描述
    var conTime: String = ""          // 问诊时间
    var result: String = ""         // 诊断结果
    var orderStatus: prescriptionOrderStatus = .unknown    // 订单状态（1待付款，2待取药，3待发货，4待签收，5待评价，6已完成，7已取消，8退款关闭）
    var drugNames: String = ""      // 药品名称
    /// 收货人信息
    var orderLogisticsDto: SEPrescriptionLogistics = SEPrescriptionLogistics()
}

/// 处方
struct SEPrescriptionDrugModel: HandyJSON {
    ///
    var id: String = ""
    /// 处方主表id
    var prescriptionId: String = ""
    /// 药品id
    var medicineId: String = ""
    /// 药品名称
    var name: String = ""
    /// 药品通用名称
    var currencyName: String = ""
    /// 药品剂型
    var drugDosageType: String = ""
    /// 药品规格
    var drugSpecification: String = ""
    /// 药品数量
    var drugNumber: String = ""
    /// 最小单位
    var baseUnit: String = ""
    /// 使用频率例如：1天1次，1天3次
    var drugFrequency: String = ""
    /// 剂量一次的使用量
    var drugDose: String = ""
    /// 剂量单位例如：ml,mg等，是字典
    var dosageUnit: String = ""
    /// 用药天数
    var drugDate: String = ""
    /// 用药方式
    var drugChannel: String = ""
    /// 用药部位
    var drugPosition: String = ""
    /// 药品费用单种药品的费用，单位是分
    var expense: Double = 0
}

/// 主次诊断
struct SEPrescriptionDiagnosis: HandyJSON {
    var id: String = ""
    var createTime: Date?
    var updateTime: Date?
    var creator: String = ""
    var `operator`: String = ""
    var isDeleted: Int = 0
    var bisId: String = ""        // 业务id
    var isMain: Int = 0         // 是否主诊断（1是，0否）
    var prefix: String = ""       // 前缀
    var middle: String = ""       // 诊断
    var suffix: String = ""       // 后缀
}

/// 收货人信息
struct SEPrescriptionLogistics: HandyJSON {
    /**
     物流信息主键id
     */
    var id: String = ""
    /**
     处方id
     */
    var preId: String = ""
    /**
     省id
     */
    var provideId: String = ""
    /**
     省name
     */
    var provideName: String = ""
    /**
     市id
     */
    var cityId: String = ""
    /**
     市name
     */
    var cityName: String = ""
    /**
     区id
     */
    var areaId: String = ""
    /**
     区name
     */
    var areaName: String = ""
    /**
     收货人姓名
     */
    var receiveName: String = ""
    /**
     收货人手机号
     */
    var receiveMobile: String = ""
    /**
     收货人详细地址
     */
    var receiverAddress: String = ""
}
